<template>
	<view class="learn-result-view">
		<template v-if="type===1">
			<image src="/static/result_success.png" mode="widthFix" class="result-icon"></image>
			<view class="result-title">您已完成全部学习</view>
			<view style="margin-top: 120rpx;">
				<van-button color="#4078E5" :custom-style="customStyle" @click="submit">提交考核申请</van-button>
			</view>

		</template>
		<template v-if="type===2">
			<image src="/static/result_wait.png" mode="widthFix" class="result-icon"></image>
			<view class="result-title">等待考核中</view>
			<view class="result-tip">提交时间：2025-08-19 15:35:04</view>
			<van-button plain color="#000000" :custom-style="customStyle+'color: #161616;'"
				@click="reback">返回</van-button>
		</template>
		<template v-if="type===3">
			<image src="/static/result_success.png" mode="widthFix" class="result-icon"></image>
			<view class="result-title">已通过考核</view>
			<view class="result-tip">请前往工作台开启工作</view>

			<van-button plain color="#000000" :custom-style="customStyle+'color: #161616;'"
				@click="reback">返回</van-button>
		</template>
		<template v-if="type===4">
			<image src="/static/result_cha.png" mode="widthFix" class="result-icon"></image>
			<view class="result-title">未通过考核</view>
			<view class="result-tip">如需申请该项目请重新考核</view>
			<van-button color="#4078E5" :custom-style="customStyle" @click="submit">重新学习</van-button>
		</template>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: 1, //1完成学习，2考核申请中，3考核通过,4未通过
				pid: '', //项目id
				customStyle: 'width: 332rpx;height: 80rpx;font-size: 32rpx;font-weight:bold'
			};
		},
		onLoad(e) {
			if (e.pid) {
				this.pid = e.pid
			}
			if (e.state) {
				this.type = Number(e.state)
			}
		},
		methods: {
			submit() {
				uni.showLoading({
					title: '数据提交中...'
				})
				this.$api.requst('/gwc/projects/commit_all', {
					id: this.pid
				}, 'POST').then((res) => {
					this.$api.showError('提交成功！')
					this.type = 2
				})
			},
			reback() {
				uni.navigateBack()
			}
		}
	}
</script>

<style lang="scss">
	.learn-result-view {
		min-height: 100vh;
		box-sizing: border-box;
		background-color: #fff;
		display: flex;
		flex-direction: column;
		align-items: center;
		padding-top: 50%;

		.result-icon {
			width: 128rpx;
			height: 128rpx;
			margin-bottom: 40rpx;
		}

		.result-title {
			font-weight: bold;
			font-size: 48rpx;
			color: #161616;
		}

		.result-tip {
			margin: 24rpx 0 58rpx;
			font-size: 26rpx;
			color: #8A8F99;
		}
	}
</style>